package com.droowa.model.service;

import java.sql.SQLException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.droowa.domain.PaymentManagement;
import com.droowa.model.dao.PaymentManagementDAO;

@Service
public class PaymentManagementServiceImpl implements PaymentManagementService{
	
	@Autowired
	private PaymentManagementDAO dao;

	@Override
	public int joinPaymentManagement(PaymentManagement paymentManagement)
			throws SQLException {
		if(getPaymentManagement()!=null){
			int update = modifyPaymentManagement(paymentManagement);
			if(update==1){
				return -1;
			}else{
				return 0;
			}
		}
		return dao.insertPaymentManagement(paymentManagement);
	}

	@Override
	public int modifyPaymentManagement(PaymentManagement paymentManagement)
			throws SQLException {
		return dao.updatePaymentManagement(paymentManagement);
	}

	@Override
	public int removePaymentManagement() throws SQLException {
		return dao.deletePaymentManagement();
	}

	@Override
	public PaymentManagement getPaymentManagement() throws SQLException {
		return dao.selectPaymentManagement();
	}
	
}
